﻿<%@ Page Title="KPI Report" Language="C#" MasterPageFile="~/App_MasterPages/Aquarius.Master"
    AutoEventWireup="true" CodeBehind="KPIExportReport.aspx.cs" Inherits="PanasonicWarranty.UI.KPIExportReport" %>

<%@ Register Src="UserControl/ucPaging.ascx" TagName="ucPaging" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CssContent" runat="server">
    <style type="text/css">
        #searching span
        {
            width: 160px;
            display: inline-block;
        }
        a.subs
        {
            color: #696969;
            text-decoration: none;
        }
        a.subs:hover
        {
            text-decoration: underline;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            dialog();
            $("#<%=txtdate_reportedFrom.ClientID%>").datepicker();
            $("#<%=txtdate_reportedTo.ClientID%>").datepicker();
        });

        function GetMT(obj) {
            var mo_guid = $("input", obj).val();
            $.ajax({
                type: "POST",
                url: "WebService.asmx/GetMO_MT",
                data: "{'mo_guid':" + JSON.stringify(mo_guid) + "}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var tbodyMT = $("#tbMT tbody");
                    var tbodyMO = $("#tbMO tbody");
                    tbodyMT.find("tr").remove();
                    tbodyMO.find("tr").remove();
                    var mo = data.d[0];
                    var mt = data.d[1];
                    for (i = 0; i < mt.length; i++) {
                        var html =
                            "<tr " + (i % 2 == 0 ? "" : "class='odd'") + ">" +
                            "   <td align='center'>" + (i + 1) + "</td>" +
                            "   <td>" + mt[i].ShortCode + "</td>" +
                            "   <td>" + mt[i].PhoneNumber + "</td>" +
                            "   <td>" + mt[i].Message + "</td>" +
                            "   <td>" + ParseJsonDate(mt[i].SentTime) + "</td>" +
                            "   <td>" + mt[i].Status + "</td>"
                        "</tr>";
                        tbodyMT.append(html);
                    }
                    for (i = 0; i < mo.length; i++) {
                        var html =
                            "<tr " + (i % 2 == 0 ? "" : "class='odd'") + ">" +
                            "   <td align='center'>" + (i + 1) + "</td>" +
                            "   <td>" + mo[i].ShortCode + "</td>" +
                            "   <td>" + mo[i].PhoneNumber + "</td>" +
                            "   <td>" + mo[i].Message + "</td>" +
                            "   <td>" + ParseJsonDate(mo[i].ReceivedTime) + "</td>" +
                            "   <td>" + mo[i].Status + "</td>"
                        "</tr>";
                        tbodyMO.append(html);
                    }
                }
            });
        }
        function dialog() {
            $("#dialog-form").dialog({
                autoOpen: false,
                width: 1024,
                modal: true,
                buttons: {
                    Cancel: function () {
                        $(this).dialog("close");
                    }
                }
            });
        }
        function showdialog() {
            $("#dialog-form").dialog("open")
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div class="row-fluid">
        <div class="span12" style="min-width: 100%; width: auto;">
            <div class="head">
                <div class="isw-grid">
                </div>
                <h1>
                    Searching</h1>
                <div class="clear">
                </div>
            </div>
            <div class="block-fluid" style="padding: 10px 0px 5px 10px">
                <table width="100%" cellspacing="0" cellpadding="0" class="">
                    <tbody>
                        <tr>
                            <td style="width: 140px">
                                Report Date
                            </td>
                            <td style="width: 240px">
                                <asp:TextBox ID="txtdate_reportedFrom" runat="server" />
                            </td>
                            <td style="width: 140px">
                                To
                            </td>
                            <td>
                                <asp:TextBox ID="txtdate_reportedTo" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Unit
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlUnit" runat="server" />
                            </td>
                            <td>
                                Phone Number
                            </td>
                            <td>
                                <asp:TextBox ID="txtPhoneNumber" runat="server" />
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div style="text-align: center; width:750px;">
                    <asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"
                        CssClass="btn" />
                </div>
            </div>
            <asp:UpdatePanel ID="udpn" runat="server">
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
                    <asp:PostBackTrigger ControlID="btnExportToExcel" />
                </Triggers>
                <ContentTemplate>
                    <div class="row-fluid">
                        <div class="span12" style="min-width: 100%; width: auto">
                            <div class="head">
                                <div class="isw-grid">
                                </div>
                                <h1>
                                    Statistic</h1>
                                <div class="clear">
                                </div>
                            </div>
                            <div class="block-fluid table-sorting">
                                <div role="grid" class="dataTables_wrapper" id="tSortable_wrapper">
                                    <div id="tSortable_length" class="dataTables_length" style="width:500px">
                                        <label>
                                            Show
                                            <asp:DropDownList ID="drdSortable_length" size="1" aria-controls="tSortable" runat="server"
                                                OnSelectedIndexChanged="drdSortable_length_SelectedIndexChanged" AutoPostBack="true">
                                                <asp:ListItem Value="5">5</asp:ListItem>
                                                <asp:ListItem Value="10">10</asp:ListItem>
                                                <asp:ListItem Value="25">25</asp:ListItem>
                                                <asp:ListItem Value="50" Selected="True">50</asp:ListItem>
                                                <asp:ListItem Value="100">100</asp:ListItem>
                                            </asp:DropDownList>
                                            entries
                                            &nbsp; &nbsp; &nbsp;
                                            <asp:LinkButton ID="btnExportToExcel" runat="server" Text="Export To Excel" 
                                            onclick="btnExportToExcel_Click" />
                                        </label>
                                    </div>
                                    <div>
                                        <uc1:ucPaging ID="pagingtop" runat="server" />
                                    </div>
                                    <asp:GridView ID="grvStatistic" runat="server" AutoGenerateColumns="true" CssClass="table dataTable"
                                        BorderStyle="None" BorderWidth="0" style="border: none; border-collapse: collapse; width:auto; min-width:100%;" OnRowCreated="grvStatistic_RowCreated"
                                        OnRowDataBound="grvStatistic_RowDataBound" >
                                            <RowStyle Wrap="false" BorderWidth="0"/>
                                        </asp:GridView>
                                    <div class="dataTables_info" id="tSortable_info">
                                        <asp:Literal ID="ltrInfo" runat="server" />
                                    </div>
                                    <div class="dataTables_paginate paging_full_numbers" id="tSortable_paginate">
                                        <uc1:ucPaging ID="pagingbottom" runat="server" />
                                    </div>
                                </div>
                                <div class="clear">
                                </div>
                            </div>
                        </div>
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </div>
    <asp:UpdateProgress ID="udprogress" DisplayAfter="1" runat="server">
        <ProgressTemplate>
            <div class="ui-widget-overlay ui-front">
                <img src="images/loading.gif" alt="Loading..." style="position: fixed; top: 50%;
                    left: 50%" />
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <div id="dialog-form" title="Mo - Mt Statistic">
        <span>Mo Statistic</span>
        <table border="1" width="100%" cellpadding="2" cellspacing="2" style="border-collapse: collapse"
            id="tbMO">
            <thead style="background: #CCCCCC; height: 35px">
                <tr>
                    <th style="width: 30px">
                        No
                    </th>
                    <th style="width: 100px">
                        Short Code
                    </th>
                    <th style="width: 120px">
                        Phone Number
                    </th>
                    <th>
                        Message
                    </th>
                    <th style="width: 180px">
                        Received Time
                    </th>
                    <th style="width: 80px">
                        Status
                    </th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
        <div class="dr">
        <span></span>
        </div>
        <span>MT Statistic</span>
        <table border="1" width="100%" cellpadding="2" cellspacing="2" style="border-collapse: collapse"
            id="tbMT">
            <thead style="background: #CCCCCC; height: 35px">
                <tr>
                    <th style="width: 30px">
                        No
                    </th>
                    <th style="width: 100px">
                        Short Code
                    </th>
                    <th style="width: 120px">
                        Phone Number
                    </th>
                    <th>
                        Message
                    </th>
                    <th style="width: 180px">
                        Sent Time
                    </th>
                    <th style="width: 80px">
                        Status
                    </th>
                </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
    <input type="hidden" id="formId" value="KPIExportReport" />
</asp:Content>
